<div class="yui-b">
    <div class="ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">
        <h1><?=lang('menu_principal');?></h1>
    </div>

    <div id="gbox_editgrid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="padding:5px;">
        &nbsp;<a href="<?=base_url();?>index.php"><?=lang('inicio');?></a><br>

        <?php if($this->modelo_modulos->get_activo('demo','empresa1')=='si'):?>
        &nbsp;<a href="<?=base_url();?>demo">Demo</a><br>
        <?php endif;?>

        <?php if($this->session->userdata('logged_in')):?>
        <form id="form0" name="form0" action="<?=base_url();?>../roundcube/" method="post" target="_blank">
            <input type="hidden" name="_token" value="13bb87b69e79e289d69794647c57295a">
            <input type="hidden" name="_action" value="login">
            <input type="hidden" name="_timezone" value="-3">
            <input type="hidden" name="_url" value="">
            <input type="hidden" name="_user" value="<?=$this->session->userdata('email')?>">
            <input type="hidden" name="_pass" value="<?=$this->session->userdata('password')?>">
            &nbsp;<a href="#" onclick="javascript:document.form0.submit()" title="Webmail">Webmails</a>
        </form>
        <?php endif;?>
    </div>

    <div style="height:5px"></div><!-- separator -->

    <div class="ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">
        <h1><?=lang('login');?></h1>
    </div>

    <div id="gbox_editgrid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="padding:5px;">
        <?php if($this->session->userdata('logged_in')):?>

        <!-- Modulos empresa 1-->
            <?php
            foreach ($this->modelo_modulos->datos->result() as $row):
                $dato = explode('_', $row->nombre);
                if(isset($dato[2])):
                    if($dato[2]=='login'):
                        if($row->empresa=='empresa1'):
                            if($row->estado=='si' && $this->modelo_modulos->get_permisos($row->nombre,'empresa1')=='si'):
                                ?>
        &nbsp;<a href="<?=base_url();?>index.php/<?=$dato[0].'_'.$dato[1]?>"><?=$row->texto_menu?></a><br>
                            <?php
                            endif;
                        endif;
                    endif;
                endif;
            endforeach;
            ?>
        <!-- fin de Modulos -->

        &nbsp;<a href="<?= site_url('/users/users')?>"><?=lang('datos_personales');?></a><br>

            <?php if ($this->session->userdata('perms')=='admin'):?>
        &nbsp;<a href="<?=base_url()?>index.php/admin/admin"><?=lang('administrador');?></a><br>
            <?php endif;?>

        &nbsp;<strong><a href="<?= site_url('/users/logout/')?>"><?=lang('salir');?></a></strong>

        <?php else:?>

        <form action="<?= site_url('/users/login')?>" method="post">
            <label for="login_username"><?=lang('e-mail');?></label>
            <input type="text" id="login_username" name="email_r" value="" size="15"  /><br />
            <label for="login_password"><?=lang('clave');?></label>
            <input type="password" id="logine_password" name="login_password" value="" size="15" /><br />
                <?php
                $letra  = $this->modelo_modulos->genRandStr(1,1,0,1,0);
                $numero = rand(0,9);

                //Check tarjeta
                $this->config->load('config_intranet');
                $rango_ip           = $this->config->item('rango_ip');
                $ip                 = $this->input->ip_address();
                $ip_cliente         = explode(".",$ip);
                $ip_cliente_interna = $ip_cliente[0].".".$ip_cliente[1];
                if ($rango_ip!=$ip_cliente_interna && "0.0"!=$ip_cliente_interna):
                    ?>
            <label for="login_tarjeta"><?=lang('tarjeta');?> <?=$letra." - ".$numero?></label>
            <input type="password" id="logine_tarjeta" name="login_tarjeta" value="" size="15" /><br />
                <?php endif; ?>

            <input type="hidden" id="logine_tarjeta" name="letra" value="<?=$letra?>" size="15" />
            <input type="hidden" id="logine_tarjeta" name="numero" value="<?=$numero?>" size="15" />
            <input type="submit" id="login" name="login" value="Login" />
        </form>
        <?php endif;?>

    </div>

    <?php if($this->session->userdata('logged_in')) { ?>
    <div style="height:5px"></div><!-- separator -->

    <div class="ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">
        <h1>Casiba</h1>
    </div>

    <div id="gbox_editgrid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="padding:5px;">

        <form id="form1" name="form1" action="<?=base_url();?>../vtigercrm2/" method="post" target="_blank">
            <input type="hidden" name="module" value="Users">
            <input type="hidden" name="action" value="Authenticate">
            <input type="hidden" name="return_module" value="Users">
            <input type="hidden" name="return_action" value="Login">
            <input type="hidden" name="user_name" value="<?=$this->session->userdata('email')?>">
            <input type="hidden" name="user_password" value="<?=$this->session->userdata('password')?>">
            <input type="hidden" name="login_theme" value="softed">
            <input type="hidden" name="login_language" value="es_es">
            &nbsp;<a href="#" onclick="javascript:document.form1.submit()" title="CRM">CRM</a>
        </form>

        <form id="form2" name="form2" action="<?=base_url();?>../wordpress/wp-login.php" method="post" target="_blank">
            <input type="hidden" name="log" value="<?=$this->session->userdata('email')?>">
            <input type="hidden" name="pwd" value="<?=$this->session->userdata('password')?>">
            <input type="hidden" name="redirect_to" value="<?=base_url();?>../wordpress/">
            <input type="hidden" name="testcookie" value="1">
            &nbsp;<a href="#" onclick="javascript:document.form2.submit()" title="Blog">Blog</a>
        </form>

        <!-- Modulos empresa 1-->
            <?php
            foreach ($this->modelo_modulos->datos->result() as $row):
                $dato = explode('_', $row->nombre);
                if(isset($dato[2])):
                    if($dato[2]=='principal'):
                        if($row->empresa=='empresa1'):
                            if($row->estado=='si' && $this->modelo_modulos->get_permisos($row->nombre,'empresa1')=='si'):
                                ?>
        &nbsp;<a href="<?=base_url();?>index.php/<?=$dato[0].'_'.$dato[1]?>"><?=$row->texto_menu?></a><br>
                            <?php
                            endif;
                        endif;
                    endif;
                endif;
            endforeach;
            ?>
        <!-- fin de Modulos -->

    </div>


        <?php if($this->modelo_modulos->get_activo('productos','empresa1')=='si'):?>
    <div style="height:5px"></div><!-- productos -->
    <div id="gbox_editgrid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="padding:5px;">

        <!-- Modulos productos 1-->
                <?php
                foreach ($this->modelo_modulos->datos->result() as $row):
                    $dato = explode('_', $row->nombre);
                    if(isset($dato[2])):
                        if($dato[2]=='productos'):
                            if($row->visible=='si'):
                                if($row->empresa=='empresa1'):
                                    if($row->estado=='si' && $this->modelo_modulos->get_permisos($row->nombre,'empresa1')=='si'):
                                        ?>
        &nbsp;<a href="<?=base_url();?>index.php/<?=$dato[0].'_'.$dato[1]?>"><?=$row->texto_menu?></a><br>
                                    <?php
                                    endif;
                                endif;
                            endif;
                        endif;
                    endif;
                endforeach;
                ?>
        <!-- fin de Modulos -->

    </div>
        <?php endif;?>


        <?php if($this->modelo_modulos->get_activo('clientes','empresa1')=='si'):?>
    <div style="height:5px"></div><!-- clientes -->
    <div id="gbox_editgrid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="padding:5px;">

        <!-- Modulos clientes 1-->
                <?php
                foreach ($this->modelo_modulos->datos->result() as $row):
                    $dato = explode('_', $row->nombre);
                    if(isset($dato[2])):
                        if($dato[2]=='clientes'):
                            if($row->visible=='si'):
                                if($row->empresa=='empresa1'):
                                    if($row->estado=='si' && $this->modelo_modulos->get_permisos($row->nombre,'empresa1')=='si'):
                                        ?>
        &nbsp;<a href="<?=base_url();?>index.php/<?=$dato[0].'_'.$dato[1]?>"><?=$row->texto_menu?></a><br>
                                    <?php
                                    endif;
                                endif;
                            endif;
                        endif;
                    endif;
                endforeach;
                ?>
        <!-- fin de Modulos -->

    </div>
        <?php endif;?>


        <?php if($this->modelo_modulos->get_activo('proveedores','empresa1')=='si'):?>
    <div style="height:5px"></div><!-- separator -->
    <div id="gbox_editgrid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="padding:5px;">

        <!-- Modulos proveedores 1-->
                <?php
                foreach ($this->modelo_modulos->datos->result() as $row):
                    $dato = explode('_', $row->nombre);
                    if(isset($dato[2])):
                        if($dato[2]=='proveedores'):
                            if($row->visible=='si'):
                                if($row->empresa=='empresa1'):
                                    if($row->estado=='si' && $this->modelo_modulos->get_permisos($row->nombre,'empresa1')=='si'):
                                        ?>
        &nbsp;<a href="<?=base_url();?>index.php/<?=$dato[0].'_'.$dato[1]?>"><?=$row->texto_menu?></a><br>
                                    <?php
                                    endif;
                                endif;
                            endif;
                        endif;
                    endif;
                endforeach;
                ?>
        <!-- fin de Modulos -->

    </div>
        <?php endif;?>

    <div style="height:5px"></div><!-- separator -->

    <div class="ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">
        <h1>Ind. Basica</h1>
    </div>
    <div id="gbox_editgrid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="padding:5px;">

        <form id="form3" name="form3" action="<?=base_url();?>../vtigercrm2basica/" method="post" target="_blank">
            <input type="hidden" name="module" value="Users">
            <input type="hidden" name="action" value="Authenticate">
            <input type="hidden" name="return_module" value="Users">
            <input type="hidden" name="return_action" value="Login">
            <input type="hidden" name="user_name" value="<?=$this->session->userdata('email')?>">
            <input type="hidden" name="user_password" value="<?=$this->session->userdata('password')?>">
            <input type="hidden" name="login_theme" value="softed">
            <input type="hidden" name="login_language" value="es_es">
            &nbsp;<a href="#" onclick="javascript:document.form3.submit()" title="CRM">CRM</a>
        </form>

        <form id="form4" name="form4" action="<?=base_url();?>../wordpressbasica/wp-login.php" method="post" target="_blank">
            <input type="hidden" name="log" value="<?=$this->session->userdata('email')?>">
            <input type="hidden" name="pwd" value="<?=$this->session->userdata('password')?>">
            <input type="hidden" name="redirect_to" value="<?=base_url();?>../wordpressbasica/">
            <input type="hidden" name="testcookie" value="1">
            &nbsp;<a href="#" onclick="javascript:document.form4.submit()" title="Blog">Blog</a>
        </form>

        <!-- Modulos empresa 2-->
            <?php
            foreach ($this->modelo_modulos->datos->result() as $row):
                $dato = explode('_', $row->nombre);
                if(isset($dato[2])):
                    if($dato[2]=='principal'):
                        if($row->empresa=='empresa2'):
                            if($row->estado=='si' && $this->modelo_modulos->get_permisos($row->nombre,'empresa2')=='si'):
                                ?>
        &nbsp;<a href="<?=base_url();?>index.php/<?=$dato[0].'_'.$dato[1]?>"><?=$row->texto_menu?></a><br>
                            <?php
                            endif;
                        endif;
                    endif;
                endif;
            endforeach;
            ?>
        <!-- fin de Modulos -->

    </div>


        <?php if($this->modelo_modulos->get_activo('productos','empresa2')=='si'):?>
    <div style="height:5px"></div><!-- separator -->
    <div id="gbox_editgrid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="padding:5px;">

        <!-- Modulos productos 2-->
                <?php
                foreach ($this->modelo_modulos->datos->result() as $row):
                    $dato = explode('_', $row->nombre);
                    if(isset($dato[2])):
                        if($dato[2]=='productos'):
                            if($row->visible=='si'):
                                if($row->empresa=='empresa2'):
                                    if($row->estado=='si' && $this->modelo_modulos->get_permisos($row->nombre,'empresa2')=='si'):
                                        ?>
        &nbsp;<a href="<?=base_url();?>index.php/<?=$dato[0].'_'.$dato[1]?>"><?=$row->texto_menu?></a><br>
                                    <?php
                                    endif;
                                endif;
                            endif;
                        endif;
                    endif;
                endforeach;
                ?>
        <!-- fin de Modulos -->


    </div>
        <?php endif;?>

        <?php if($this->modelo_modulos->get_activo('clientes','empresa2')=='si'):?>
    <div style="height:5px"></div><!-- separator -->
    <div id="gbox_editgrid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="padding:5px;">

        <!-- Modulos clientes 2-->
                <?php
                foreach ($this->modelo_modulos->datos->result() as $row):
                    $dato = explode('_', $row->nombre);
                    if(isset($dato[2])):
                        if($dato[2]=='clientes'):
                            if($row->visible=='si'):
                                if($row->empresa=='empresa2'):
                                    if($row->estado=='si' && $this->modelo_modulos->get_permisos($row->nombre,'empresa2')=='si'):
                                        ?>
        &nbsp;<a href="<?=base_url();?>index.php/<?=$dato[0].'_'.$dato[1]?>"><?=$row->texto_menu?></a><br>
                                    <?php
                                    endif;
                                endif;
                            endif;
                        endif;
                    endif;
                endforeach;
                ?>
        <!-- fin de Modulos -->

    </div>
        <?php endif;?>

        <?php if($this->modelo_modulos->get_activo('proveedores','empresa2')=='si'):?>
    <div style="height:5px"></div><!-- separator -->
    <div id="gbox_editgrid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="padding:5px;">

        <!-- Modulos proveedores 2-->
                <?php
                foreach ($this->modelo_modulos->datos->result() as $row):
                    $dato = explode('_', $row->nombre);
                    if(isset($dato[2])):
                        if($dato[2]=='proveedores'):
                            if($row->visible=='si'):
                                if($row->empresa=='empresa2'):
                                    if($row->estado=='si' && $this->modelo_modulos->get_permisos($row->nombre,'empresa2')=='si'):
                                        ?>
        &nbsp;<a href="<?=base_url();?>index.php/<?=$dato[0].'_'.$dato[1]?>"><?=$row->texto_menu?></a><br>
                                    <?php
                                    endif;
                                endif;
                            endif;
                        endif;
                    endif;
                endforeach;
                ?>
        <!-- fin de Modulos -->

    </div>
        <?php endif;?>


        <?php } ?>
    <!--  <div style="height:5px"></div>
      <div class="ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">
          <h1><?=lang('lenguaje');?></h1>
      </div>
      <div id="gbox_editgrid" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" dir="ltr" style="padding:5px;">
          <a href="<?=base_url();?>index.php/idiomas/idioma2/spanish"><img src="<?=base_url();?>images/es.png" alt="Espa&ntilde;ol"></a>
          <a href="<?=base_url();?>index.php/idiomas/idioma2/english"><img src="<?=base_url();?>images/us.png" alt="English"></a>
          <a href="<?=base_url();?>index.php/idiomas/idioma2/italy"><img src="<?=base_url();?>images/it.png" alt="Italy"></a>
          <a href="<?=base_url();?>index.php/idiomas/idioma2/portugues"><img src="<?=base_url();?>images/pt.png" alt="Portugues"></a>
      </div> -->
</div>
<!-- fin menu -->
